<link href="ccs.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>yellowpages.vn - Vietnam Business Yellow Pages Directory - Trang Vang Vietnam</TITLE>
<script language="javascript">{variable}</script>
<body topmargin="0px" bottommargin="0px" leftmargin="0px" rightmargin="0px">
<table border="0" align="center" cellpadding="0" cellspacing="1" class="tableF">
	<tr>
		<td colspan="2" class="head">
		<DIV class=tcat style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px; TEXT-ALIGN: center"><strong>Category</strong></DIV>
		</td>
	</tr>
	<tr>
		<td colspan="2" class="quote">&nbsp;{l_mess}</td>
	</tr>
	<TR>
		<TD height="25" class="row1">&nbsp;	</TD>
		<TD class="row1">&nbsp;</TD>
	</TR>
	<TR align="center">
		<TD height="25" class="row1">&nbsp; 
		<select name="levelone" size="8" id="levelone" style="width:275px;" onChange="OnSelectCat(1)"></select></TD>
		<TD class="row1">&nbsp;
		<select name="leveltwo" size="8" id="leveltwo" style="width:275px;" onChange="OnSelectCat(2)"></select> </TD>
	</TR>
	<TR>
		<TD height="24" colspan="2" align="center" class="row1">
		<input name="btAdd" type="button" id="btAdd" onClick="AddCategory()" value="Add">&nbsp; 							
		<input type="button" name="Submit2" value="Remove" onClick="DeleteCategory()"><br>
		<select size="5" style="width:500px" name="cat" id="cat">
		<!-- BEGIN catrow -->
		<option value="{catrow.catValue}">{catrow.catCaption}</option>
		<!-- END catrow -->
		</select></TD>
	</TR>
	<TR>
		<TD height="41" colSpan=2 align=center valign="middle" class="row1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="button" name="Submit3" value="Submit" onClick="doaddCat()">                
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
	</TR>
</table>
<script language="JavaScript">
	var s1 = document.getElementById("levelone")
	var s2 = document.getElementById("leveltwo")
	var s = document.getElementById("cat")	
	function OnLoadSelect(){
		for(i=0;i<arr1.length;i++){
			s1.options[s1.length] = new Option(arr1[i],arr1[i+1])
			i=i+1
		}
	}
	function OnSelectCat(lv){
		if(lv==1){		
			RemoveSelect(2);
			for(i=0;i<arr2.length;i++){
				if(arr2[i][0]==s1.options[s1.selectedIndex].value){
					for(j=1;j<arr2[i].length;j++){
						s2.options[s2.length] = new Option(arr2[i][j],arr2[i][j+1])						
						j=j+1
					}
				}
			}
		}else if(lv==2){
			RemoveSelect(3);
			for(i=0;i<arr3.length;i++){
				if(arr3[i][0]==s2.options[s2.selectedIndex].value){
					for(j=1;j<arr3[i].length;j++){
						s3.options[s3.length] = new Option(arr3[i][j],arr3[i][j+1])
						j=j+1
					}
				}
			}
		}else if(lv==3){
			RemoveSelect(4);
			for(i=0;i<arr4.length;i++){
				if(arr4[i][0]==s3.options[s3.selectedIndex].value){
					for(j=1;j<arr4[i].length;j++){
						s4.options[s4.length] = new Option(arr4[i][j],arr4[i][j+1])
						j=j+1
					}
				}
			}
		}
			DisablesButton()
	}
	function RemoveSelect(lv){
		for(k=lv;k<5;k++){
			if(k==2){
				x = s2.length
				y = 0
				while (y<x){
					s2.remove(s2.options[y].index)
					x--
				}
			}
		}	
	}
 	function AddCategory(){
		var txt = ''
		var vl = ''
		if(s.length>30){
		return
		}
		if(s1.length > 0){
			if(s1.selectedIndex > -1){
				txt = s1.options[s1.selectedIndex].text
				vl = s1.options[s1.selectedIndex].value
			}
		}
		if(s2.length > 0){
			if(s2.selectedIndex > -1){
				txt = txt + '>>' + s2.options[s2.selectedIndex].text
				vl = vl + '-' + s2.options[s2.selectedIndex].value
			}
		}
		var fg = true
		for(v=0;v<s.length;v++){
			if(s.options[v].value == vl){fg = false}
		}
		if(fg == true){s.options[s.length] = new Option(txt,vl)}
	}
	function doaddCat(){
		  if(s.options.length<1){
			alert('Please chose a one.') ;
			return
		  }
		 if (window.opener == null) return ; 
		 var parentObj=window.opener.document.getElementById('optCategory') ;
		 if (parentObj==null) return ;
		 parentObj.length = 0;
		 for(var j=0;j<s.length;j++){                 
			 window.opener.addOption(s.options[j].innerHTML,s.options[j].value)
		 }
		 parentObj.options[0].selected=true
		 window.close() ;
	}	
	function DeleteCategory(){
		if(s.length > 0){
			if(s.selectedIndex > -1){
				s.remove(s.selectedIndex);
			}
		}
	}
	function DisablesButton(){
	
		document.getElementById("btAdd").disabled = true		 	 

		if(s2.length > 0){			
			if(s2.selectedIndex > -1){				 
				document.getElementById("btAdd").disabled = false
			}
		}
	}	
	//+++++++++++++++++++++++++++++++++
	 OnLoadSelect()
	 DisablesButton();
	//+++++++++++++++++++++++++++++++++++++ 
</script>
</body>  